package com.wzcl.app.dao.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wzcl.app.dao.model.common.Base;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@Data
@Entity
@Table(name = "wrongTopic",
        indexes = {
                @Index(columnList = "userPhone")
        }
)
@ApiModel(value = "错题记录表")
@EntityListeners(AuditingEntityListener.class)
public class WrongTopic implements Base {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @ApiModelProperty(value = "用户手机号,相当于userName")
    private String userPhone;

    @ApiModelProperty(value = "用户的答案")
    @Column(columnDefinition = "text")
    private String userAnswer;

    @CreatedDate
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @LastModifiedDate
    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"knowledgePoint"})
    @ApiModelProperty(value = "错题知识点+题目的关联")
    @JoinColumn(name = "topicAndKnowledgePointId")
    private TopicAndKnowledgePoint topicAndKnowledgePoint;
}
